package org.jeecg.modules.maxkey.oauth;

import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.request.AuthDefaultRequest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

public enum AuthMaxkeySource implements AuthSource {
    MAXKEY {
        /**
         * 授权的api
         *
         * @return url
         */
        @Override
        public String authorize() {
            return MaxkeyConfig.serverUrl + "/sign/authz/oauth/v20/authorize";
        }

        /**
         * 获取accessToken的api
         *
         * @return url
         */
        @Override
        public String accessToken() {
            return MaxkeyConfig.serverUrl + "/sign/authz/oauth/v20/token";
        }


        /**
         * 获取用户信息的api
         *
         * @return url
         */
        @Override
        public String userInfo() {
            return MaxkeyConfig.serverUrl + "/sign/api/oauth/v20/me";
        }

        /**
         * 取消授权的api
         *
         * @return url
         */
        @Override
        public String revoke() {
            return null;
        }

        /**
         * 刷新授权的api
         *
         * @return url
         */
        @Override
        public String refresh() {
            return null;
        }

    };

    @Component
    static class MaxkeyConfig {

        private static String serverUrl;

        @Value("${third-app.type.MAXKEY.serverUrl}")
        public void init(String serverUrl) {
            MaxkeyConfig.serverUrl = serverUrl;
        }
    }


}
